apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 27
        versionCode 22
        versionName "0.2.8"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    externalNativeBuild{
        ndkBuild{
            path "src/main/jni/Android.mk"
        }
    }
}

task javah(type: Exec, dependsOn: 'compileReleaseJavaWithJavac') {
    commandLine 'javah', '-jni',
            '-d', 'src/main/jni/image/javah',
            '-cp', "${android.getSdkDirectory().getAbsolutePath()}/platforms/android-27/android.jar;build/intermediates/classes/release",
            'com.hippo.image.Image',
            'com.hippo.image.StaticImage',
            'com.hippo.image.StaticDelegateImage',
            'com.hippo.image.AnimatedImage',
            'com.hippo.image.AnimatedDelegateImage',
            'com.hippo.image.BitmapDecoder',
            'com.hippo.image.BitmapRegionDecoder'
}

dependencies {
    implementation 'com.android.support:support-annotations:27.1.0'
    testImplementation 'junit:junit:4.12'
}

// build a jar with source files
task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    failOnError  false
    source = android.sourceSets.main.java.sourceFiles
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    classpath += configurations.compile
}

// build a jar with javadoc
task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar
    archives javadocJar
}
